<?php

namespace app\index\controller;

use think\Controller;
use think\Facade\Request;
use app\index\controller\Order;
use Units\RoutePlanner;
use Units\Area;
use app\index\model\Order as OrderModel;
use Units\ChunkRouter;
use app\index\model\Router;
use think\Db;
use Units\TransformOrderField;
use app\index\model\Vehicle;
use Units\Http;
use think\Facade\Config;
use app\index\model\Customer;
use app\index\model\Warehouse;
class Index extends Base
{

    public function index()
    {
        /*从SAP读取数据*/
        // $orders = Http::instance()->request(Config::get('SAP_API_URL'))->toArray();
        // var_dump($orders);die;
        //插入order表
        $orders = Db::table('tb_120_invoice_tms')->select();
        foreach ( $orders as $key=> $item ) {
            $newOrders = TransformOrderField::instance()->transformField($item);
          //  OrderModel::create($newOrders);
        }
        $wareHouse = Warehouse::all();
        return $this->fetch('',['wareHouse'=>$wareHouse]);
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        //
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
